package com.killer.goods.controller;


import com.killer.common.entity.Result;
import com.killer.db.controller.BaseController;
import com.killer.goods.entity.Goods;
import com.killer.goods.entity.Spu;
import com.killer.goods.service.ISpuService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 标准产品单位表 前端控制器
 * </p>
 *
 * @author killer
 * @since 2021-08-29
 */
@RestController
@RequestMapping("/spu")
public class SpuController extends BaseController<ISpuService, Spu> {

    @GetMapping("/batchGetMarketableSpu")
    public Result<List<Spu>> batchGetMarketableSpu(@RequestParam Long startId) {
        List<Spu> spuList=baseService.batchGetMarketableSpu(startId);
        return Result.success(spuList);
    }

    @PostMapping("/addGoods")
    public Result addGoods(@RequestBody Goods goods) {
        baseService.addGoods(goods);
        return Result.success();
    }

    @GetMapping("/findGoodsById")
    public Result<Goods> findGoodsById(@RequestParam Long id) {
        Goods goods=baseService.findGoodsById(id);
        return Result.success(goods);
    }

    @PostMapping("/updateGoods")
    public Result updateGoods(@RequestBody Goods goods) {
        baseService.updateGoods(goods);
        return Result.success();
    }

    @PostMapping("/audit")
    public Result autit(@RequestParam("id") Long id) {
        baseService.autit(id);
        return Result.success();
    }

    @PostMapping("/pull")
    public Result pull(@RequestParam("id") Long id) {
        baseService.pull(id);
        return Result.success();
    }

    @PostMapping("/put")
    public Result put(@RequestParam("id") Long id) {
        baseService.put(id);
        return Result.success();
    }
}
